package homewoek12月22号.demo1.d2;

import org.apache.commons.io.FileUtils;

import java.io.File;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        String s="src/com/czxy/demo1/d2/pingping.jpg";
        byte[] bytes = FileUtils.readFileToByteArray(new File(s));
        if (s.contains("jpg")){
            if (bytes.length<2*1024*1024){
                byte[] arr =new byte[bytes.length];
                for (int i = bytes.length - 1; i >= 0; i--) {
                    arr[i]=bytes[i];
                }
                FileUtils.writeByteArrayToFile(new File("src/com/czxy/demo1/d1/pingping.jpg"),arr);
                System.out.println("上传成功！");
            }else{
                System.out.println("文件过大");
            }
        }else {
            System.out.println("不是图片");
        }
    }
}
